package tech.aistar.prj.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import tech.aistar.prj.model.dto.VideoDTO;
import tech.aistar.prj.model.dto.VideoQueryDTO;
import tech.aistar.prj.model.pojo.User;
import tech.aistar.prj.model.pojo.Video;

import java.util.List;

public interface VideoMapper {
//    @Select("select * from jdbc_video where username=#{value}")
//    User findByUserName(String username);

    @Select("select * from jdbc_video")
    List<Video> findAll();
//    List<VideoDTO> findMoreConditional(VideoQueryDTO videoQueryDTO);
    List<VideoDTO> findMoreConditional(VideoQueryDTO videoQueryDTO);
    List<Video> findByUser(String username);
    @Insert("insert into jdbc_video values(#{id},#{title},#{videoUrl},#{userId},#{createDate},#{likes},#{score},#{status})")
    int save(Video video);
    @Update("update jdbc_video set status=#{status} where id=#{id} and user_id=#{userId}")
    int updateStatus(@Param("id") Integer id,@Param("userId") Integer userId,@Param("status") Integer status);
    @Update("update jdbc_video set title=#{title},video_url=#{videoUrl},status=#{status} where id=#{id}")
    int updateVideoWithUser(Video v);
    @Select("select * from jdbc_video where id=#{id}")
    Video getById(Integer id);
}
